

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main" />
        <title>Report List</title>
    </head>
    <body>
        <div class="nav">
	    <g:if test="${session.user.role.name == 'Student'}">
            <span class="menuButton"><g:link class="home" controller="person" action="home">Home</g:link></span>
            <span class="menuButton"><g:link class="create" action="create">New Report</g:link></span>
            </g:if>
	    <g:if test="${session.user.role.name == 'Organiser' | session.user.role.name == 'Supervisor'}">
	    <span class="menuButton"><g:link class="home" controller="person" action="home">Home</g:link></span>
	    </g:if>            
        </div>
        <div class="body">
            <h1>Report List</h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <div class="list">
                <table>
                    <thead>
                        <tr>
                        
                   	        <g:sortableColumn property="id" title="Id" />
                        
				<g:sortableColumn property="student" title="Student" />

				<g:sortableColumn property="project" title="Project" />

                   	        <g:sortableColumn property="associatedFile" title="Associated File" />
                        
                   	        <g:sortableColumn property="submitDate" title="Submit Date" />
				<th class="sortable">Comment</th>
                        </tr>
                    </thead>
                    <tbody>
			
			
			<g:each in="${reportList}" status="i" var="report">
                        
			<tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
			 
                            <td><g:link action="show" id="${report.id}">${fieldValue(bean:report, field:'id')}</g:link></td>
                        
			    <td>${fieldValue(bean:report, field:'student')}</td>

			    <td>${fieldValue(bean:report, field:'project')}</td

                            <td>
    				<g:if test="${report.fileName?.length() > 0}">
        		          <g:link action="downloadFile" id="${report.id}">${fieldValue(bean:report, field:'fileName')}</g:link>
    				</g:if>
			    </td>
                        
                            <td>${fieldValue(bean:report, field:'submitDate')}</td>
                       
			    <td>
			<g:if test="${report.getComments().size() > 0}">
				<g:link controller="comment" action="list" params="[reportId:report.id]">View Comment</g:link>	 
			</g:if>
			<g:else>
				<g:link controller="comment" action="list" params="[reportId:report.id]">Add Comment</g:link>	 
			</g:else>
			    </td>
			</tr>
                        
			</g:each>

                    </tbody>
                </table>
            </div>
            <div class="paginateButtons">
                <input type="button" value="Back" onClick="history.back()">
            </div>
        </div>
    </body>
</html>
